001 /* 002 * Copyright 2005 Stephen J. McConnell 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.tools.tasks; 020 021 import org.apache.tools.ant.BuildException; 022 import org.apache.tools.ant.taskdefs.Property; 023 024 /** 025 * Build a set of projects taking into account dependencies within the 026 * supplied fileset. 027 * 028 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 029 * @version 1.1.1 030 */ 031 public class PropertyTask extends FeatureTask 032 { 033 private String m_property; 034 035 /** 036 * Set the property name. The property task will assign a value to the 037 * property declared by the supplied name. 038 * @param property the property name 039 */ 040 public void setName( final String property ) 041 { 042 m_property = property; 043 } 044 045 /** 046 * Task execution. 047 * @exception BuildException if an error occurs 048 */ 049 public void execute() throws BuildException 050 { 051 if( null == m_property ) 052 { 053 final String error = 054 "Missing name attribute."; 055 throw new BuildException( error ); 056 } 057 058 final String value = super.resolve(); 059 if( null != value ) 060 { 061 final Property property = (Property) getProject().createTask( "property" ); 062 property.init(); 063 property.setName( m_property ); 064 property.setValue( value ); 065 property.setTaskName( getTaskName() ); 066 property.execute(); 067 } 068 else 069 { 070 final String error = 071 "Unrecognized or unsupported feature [" 072 + getFeature() 073 + "]."; 074 throw new BuildException( error ); 075 } 076 } 077 }